```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据库核心概念：主键与索引</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
        }
        h1, h2, h3 {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        }
        .feature-icon {
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            margin-bottom: 1rem;
        }
        .code-block {
            background-color: #f6f8fa;
            border-radius: 8px;
            padding: 1rem;
            font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
            position: relative;
        }
        .code-block::before {
            content: "SQL";
            position: absolute;
            top: 0;
            right: 0;
            padding: 0.25rem 0.75rem;
            background-color: #e1e4e8;
            border-radius: 0 8px 0 8px;
            font-size: 0.8rem;
            color: #586069;
        }
        .highlight {
            position: relative;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(110, 142, 251, 0.3);
            z-index: -1;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">数据库核心概念</h1>
                    <h2 class="text-2xl md:text-3xl font-semibold mb-6">主键与索引的深度解析</h2>
                    <p class="text-xl opacity-90 mb-8">探索数据库中两个关键概念的差异与联系，优化您的数据库设计</p>
                    <a href="#content" class="bg-white text-purple-600 hover:bg-purple-100 px-6 py-3 rounded-lg font-medium transition duration-300 inline-flex items-center">
                        开始探索 <i class="fas fa-arrow-down ml-2"></i>
                    </a>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid bg-white bg-opacity-20 p-6 rounded-xl">
                        graph TD
                            A[数据库关键概念] --> B[主键 Primary Key]
                            A --> C[索引 Index]
                            B --> D[唯一标识]
                            B --> E[不能为NULL]
                            B --> F[一个表只能有一个]
                            C --> G[提高查询速度]
                            C --> H[可以有多个]
                            C --> I[可以包含NULL]
                            B & C --> J[影响数据库性能]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main id="content" class="container mx-auto max-w-6xl px-4 py-16">
        <!-- Key Concepts -->
        <section class="mb-20">
            <div class="text-center mb-12">
                <span class="text-purple-600 font-semibold tracking-wider">核心概念</span>
                <h2 class="text-3xl font-bold mt-3">主键与索引的本质区别</h2>
                <p class="text-gray-600 max-w-2xl mx-auto mt-4">理解这些基础概念是进行高效数据库设计和优化的第一步</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <!-- Primary Key Card -->
                <div class="bg-white rounded-xl p-8 card-hover">
                    <div class="feature-icon bg-purple-100 text-purple-600">
                        <i class="fas fa-key text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-4">主键 (Primary Key)</h3>
                    <p class="text-gray-600 mb-6">数据库中的唯一标识符，确保数据的完整性和唯一性</p>
                    
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-purple-600 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><strong>定义：</strong>主键是一种约束，用于唯一标识表中的每一行数据</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-purple-600 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><strong>关键特点：</strong>不能为NULL，必须唯一，一个表只能有一个主键</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-purple-600 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><strong>作用：</strong>确保数据唯一性，建立表间关系</p>
                        </div>
                    </div>
                    
                    <div class="mt-6">
                        <h4 class="font-semibold mb-2">语法示例：</h4>
                        <div class="code-block">
                            CREATE TABLE employees (
                                employee_id INT PRIMARY KEY,
                                first_name VARCHAR(50),
                                last_name VARCHAR(50)
                            );
                        </div>
                    </div>
                </div>

                <!-- Index Card -->
                <div class="bg-white rounded-xl p-8 card-hover">
                    <div class="feature-icon bg-blue-100 text-blue-600">
                        <i class="fas fa-search text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-4">索引 (Index)</h3>
                    <p class="text-gray-600 mb-6">数据库性能优化的利器，加速数据检索过程</p>
                    
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-blue-600 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><strong>定义：</strong>一种数据结构，用于提高数据库表的检索速度</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-blue-600 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><strong>关键特点：</strong>可以有多个，可以包含NULL值，不保证唯一性</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-blue-600 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><strong>作用：</strong>提高查询性能，加速数据检索</p>
                        </div>
                    </div>
                    
                    <div class="mt-6">
                        <h4 class="font-semibold mb-2">语法示例：</h4>
                        <div class="code-block">
                            -- 在 employees 表的 employee_id 列上创建索引
                            CREATE INDEX idx_employee_id 
                            ON employees(employee_id);
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-20">
            <div class="text-center mb-12">
                <span class="text-purple-600 font-semibold tracking-wider">对比分析</span>
                <h2 class="text-3xl font-bold mt-3">主键与索引的核心差异</h2>
                <p class="text-gray-600 max-w-2xl mx-auto mt-4">通过六个维度深入理解这两个概念的区别</p>
            </div>

            <div class="bg-white rounded-xl overflow-hidden shadow-sm">
                <div class="grid grid-cols-1 md:grid-cols-7 border-b border-gray-200">
                    <div class="p-4 font-semibold bg-gray-50 hidden md:block"></div>
                    <div class="p-4 font-semibold text-center">唯一性</div>
                    <div class="p-4 font-semibold text-center">NULL值</div>
                    <div class="p-4 font-semibold text-center">个数限制</div>
                    <div class="p-4 font-semibold text-center">物理结构</div>
                    <div class="p-4 font-semibold text-center">主要目的</div>
                    <div class="p-4 font-semibold text-center">语法定义</div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-7 border-b border-gray-200 hover:bg-gray-50">
                    <div class="p-4 font-semibold bg-gray-50 md:bg-white">主键</div>
                    <div class="p-4 text-center">必须唯一</div>
                    <div class="p-4 text-center">不允许NULL</div>
                    <div class="p-4 text-center">仅一个</div>
                    <div class="p-4 text-center">影响存储</div>
                    <div class="p-4 text-center">确保数据唯一性</div>
                    <div class="p-4 text-center">PRIMARY KEY约束</div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-7 hover:bg-gray-50">
                    <div class="p-4 font-semibold bg-gray-50 md:bg-white">索引</div>
                    <div class="p-4 text-center">可以重复</div>
                    <div class="p-4 text-center">允许NULL</div>
                    <div class="p-4 text-center">多个允许</div>
                    <div class="p-4 text-center">逻辑结构</div>
                    <div class="p-4 text-center">提高查询速度</div>
                    <div class="p-4 text-center">CREATE INDEX语句</div>
                </div>
            </div>
        </section>

        <!-- Key Takeaways -->
        <section class="bg-purple-50 rounded-xl p-8 md:p-12 mb-20">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/3 mb-8 md:mb-0">
                    <div class="text-purple-600 text-5xl font-bold mb-2">关键</div>
                    <div class="text-3xl font-bold text-gray-800">总结要点</div>
                </div>
                <div class="md:w-2/3">
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mt-1 text-purple-600">
                                <i class="fas fa-database"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><span class="highlight font-medium">主键是数据库的一种约束</span>，表示数据的唯一，不可重复。主键自动创建一个主键索引</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mt-1 text-purple-600">
                                <i class="fas fa-table"></i>
                            </div>
                            <p class="ml-3 text-gray-700"><span class="highlight font-medium">索引是数据库的对象</span>，可以提高数据的检索速度，但不改变数据的唯一性约束</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 mt-1 text-purple-600">
                                <i class="fas fa-lightbulb"></i>
                            </div>
                            <p class="ml-3 text-gray-700">在实际应用中，<span class="highlight font-medium">主键保证数据的完整性</span>，而<span class="highlight font-medium">索引优化查询性能</span>，两者相辅相成</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Practical Tips -->
        <section class="mb-20">
            <div class="text-center mb-12">
                <span class="text-purple-600 font-semibold tracking-wider">实践建议</span>
                <h2 class="text-3xl font-bold mt-3">数据库设计最佳实践</h2>
                <p class="text-gray-600 max-w-2xl mx-auto mt-4">合理使用主键和索引可以显著提升数据库性能和数据完整性</p>
            </div>

            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-lg shadow-sm border-l-4 border-purple-500">
                    <h3 class="font-bold text-lg mb-3 flex items-center">
                        <i class="fas fa-fingerprint text-purple-500 mr-2"></i> 主键选择
                    </h3>
                    <p class="text-gray-600">为每个表选择最合适的列作为主键。通常使用自增整数或UUID，确保简单且唯一。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm border-l-4 border-blue-500">
                    <h3 class="font-bold text-lg mb-3 flex items-center">
                        <i class="fas fa-tachometer-alt text-blue-500 mr-2"></i> 索引策略
                    </h3>
                    <p class="text-gray-600">在经常用于查询、排序和连接的列上创建索引，但要避免过度索引导致写操作变慢。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-sm border-l-4 border-green-500">
                    <h3 class="font-bold text-lg mb-3 flex items-center">
                        <i class="fas fa-project-diagram text-green-500 mr-2"></i> 联合主键
                    </h3>
                    <p class="text-gray-600">在关系表中，考虑使用联合主键来建立表间关系，确保数据完整性。</p>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto px-4 max-w-6xl">
            <div class="text-center">
                <h3 class="text-xl font-medium text-white mb-2">技术小馆</h3>
                <p class="mb-6">探索技术的无限可能</p>
                <a href="http://www.yuque.com/jtostring" class="text-purple-400 hover:text-purple-300 transition duration-300 inline-block">
                    <i class="fas fa-globe mr-2"></i> www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```